package com.amap.gunfighting;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

public class MainActivity extends Activity 
{
	// definitions
	MediaPlayer explosion;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // jump to the login page after 4 seconds' sleeping
        explosion = MediaPlayer.create(MainActivity.this, R.raw.explosion);
		explosion.start();
		Thread timer = new Thread(){
			public void run(){
				try {
					sleep(4000);
				} catch(InterruptedException e){
					e.printStackTrace();
				}finally{
					//this is the standard method for active the second activity. Do NOT write it into three steps.
    				startActivity(new Intent(MainActivity.this, Login.class));
    				//finish the login activity
    				MainActivity.this.finish();
				}
			}
		};
		timer.start();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    protected void onPause() {
 		// TODO Auto-generated method stub
 		super.onPause();
 		explosion.release();
 		finish();
 	}
}
